package com.yiyefanchen.ai.controller;

import com.yiyefanchen.ai.entity.vo.MessageVO;
import com.yiyefanchen.ai.service.DashScopeChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/dashscope/conversation")
public class DashscopeChatHistoryController {

    @Autowired
    DashScopeChatService dashScopeChatService;

    @GetMapping("/ids")
    public List<String> findConversationIds() {
        return dashScopeChatService.findConversationIds();
    }

    @GetMapping("/history/{conversationId}")
    public List<MessageVO> findByConversationId(@PathVariable("conversationId") String conversationId) {
        return dashScopeChatService.findByConversationId(conversationId);
    }

    @GetMapping("/delete/{conversationId}")
    public void deleteByConversationId(@PathVariable("conversationId") String conversationId) {
        dashScopeChatService.deleteByConversationId(conversationId);
    }
}
